package com.pojoin.cms.domain.persistence;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import com.pojoin.cms.domain.Role;
import com.pojoin.cms.domain.alter.UserAlter;

@Entity
@Table(name = "user")
public class UserPersistence extends UserAlter {

	@Override
	@Column
	public Integer getDeleted() {
		return super.getDeleted();
	}

	@Override
	@Column
	public String getEmail() {
		return super.getEmail();
	}

	@Override
	@Column
	public String getUserName() {
		return super.getUserName();
	}

	@Override
	@Column
	public String getNickName() {
		return super.getNickName();
	}

	@Override
	@Column
	public String getPassword() {
		return super.getPassword();
	}

	@Override
	@Column
	public String getRemark() {
		return super.getRemark();
	}

	@Override
	@ManyToMany(
			targetEntity=RolePersistence.class,
			fetch=FetchType.EAGER
			)
	@JoinTable(
			name="user_role",
			joinColumns={@JoinColumn(name="userId")},
			inverseJoinColumns={@JoinColumn(name="roleId")}
			)
	public Set<Role> getRoles() {
		return super.getRoles();
	}

	@Override
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getUserId() {
		return super.getUserId();
	}
	
	public void setUserId(Long id){
		this.userId = id;
	}

}
